﻿using System.Reflection;

namespace AntBlazorTableSample.WebApp
{
    public static class Utils
    {
        public static Type? GetUnderlyingType(this Type? type)
        {
            Type? targetType;
            if (type is not null && type.GetTypeInfo().IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>))
            {
                targetType = Nullable.GetUnderlyingType(type);
            }
            else
            {
                targetType = type;
            }
            return targetType;
        }
    }
}
